
var punishId = getUrlParms("punishId");
var stuInfoId = getUrlParms("stuInfoId");
var stuNum = getUrlParms("stuNum");
var stuName = getUrlParms("stuName");
var stuSex = getUrlParms("stuSex");
var academyName = getUrlParms("academyName");
var punishTime = getUrlParms("punishTime");
var punishType = getUrlParms("punishType");

$(document).ready(function() {
    $("input[name='punishId']").val(punishId);
    $("input[name='stuInfoId']").val(stuInfoId);
    $("input[name='stuNum']").val(stuNum);
    $("input[name='stuName']").val(stuName);
    $("input[name='stuSex']").val(stuSex);
    $("input[name='academyName']").val(academyName);
    $("input[name='punishTime']").val(punishTime);
    $("textarea[name='punishType']").val(punishType);

});

$(document).on('click', '#update-btn', function() {
    var punishId=$("input[name='punishId']").val();
    var punishType=$("textarea[name='punishType']").val();
    $.ajax({
        url: "http://localhost:8080/punish/updatePunish",
        type: "GET",
        data:"punishId="+punishId+"&punishType="+punishType,
        dataType: "json",
        success:function () {
            layer.load(1, {
                shade: [0.1,'#fff'] //0.1透明度的白色背景
            });
            setTimeout(function () {
                layer.msg('更新成功')
            },1500);

            var index = parent.layer.getFrameIndex(window.name);
            setTimeout(function(){
                parent.layer.close(index)
            }, 2000);
            parent.location.reload()
        },
        error:function () {
            layer.alert("网络在开小差~再试一次吧！");
        }
    });
});


function getUrlParms(name){
    var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
    var r = window.location.search.substr(1).match(reg);
    if(r!=null)
        return decodeURI(r[2]);
    return null;
}

